From 98321440ec5681052fc4cadfaed5471b01cfd451 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Sat, 17 Mar 2007 23:55:03 +0000 Subject: [PATCH] Replace VDI.location with a more generic VDI.other_config map. Remove VDI.sector_size. Xend work by Tom Wilkie . Signed-off-by: Ewan Mellor --- docs/xen-api/xenapi-datamodel.tex | 151 ++++++++++++++++++++---- tools/libxen/include/xen_vbd.h | 1 - tools/libxen/include/xen_vdi.h | 44 +++++-- tools/libxen/src/xen_vbd.c | 3 - tools/libxen/src/xen_vdi.c | 90 ++++++++++---- tools/libxen/test/test_bindings.c | 3 +- tools/python/scripts/test_hvm_create.py | 3 +- tools/python/scripts/test_vm_create.py | 6 +- tools/python/scripts/xapi.py | 11 +- tools/python/scripts/xapi.vdicfg.py | 3 +- tools/python/xen/xend/XendAPI.py | 19 +-- tools/python/xen/xend/XendVDI.py | 17 +-- 12 files changed, 258 insertions(+), 93 deletions(-) diff --git a/docs/xen-api/xenapi-datamodel.tex b/docs/xen-api/xenapi-datamodel.tex index 1b18834d03..4a11ef0d9b 100644 --- a/docs/xen-api/xenapi-datamodel.tex +++ b/docs/xen-api/xenapi-datamodel.tex @@ -9359,10 +9359,10 @@ $\mathit{RO}_\mathit{run}$ & {\tt VBDs} & (VBD ref) Set & list of vbds that ref $\mathit{RO}_\mathit{run}$ & {\tt crash\_dumps} & (crashdump ref) Set & list of crash dumps that refer to this disk \\ $\mathit{RW}$ & {\tt virtual\_size} & int & size of disk as presented to the guest (in bytes). Note that, depending on storage backend type, requested size may not be respected exactly \\ $\mathit{RO}_\mathit{run}$ & {\tt physical\_utilisation} & int & amount of physical space that the disk image is currently taking up on the storage repository (in bytes) \\ -$\mathit{RO}_\mathit{ins}$ & {\tt sector\_size} & int & sector size of VDI (in bytes) \\ $\mathit{RO}_\mathit{ins}$ & {\tt type} & vdi\_type & type of the VDI \\ $\mathit{RW}$ & {\tt sharable} & bool & true if this disk may be shared \\ $\mathit{RW}$ & {\tt read\_only} & bool & true if this disk may ONLY be mounted read-only \\ +$\mathit{RW}$ & {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\ \hline \end{longtable} \subsection{RPCs associated with class: VDI} @@ -9812,13 +9812,13 @@ value of the field \vspace{0.3cm} \vspace{0.3cm} \vspace{0.3cm} -\subsubsection{RPC name:~get\_sector\_size} +\subsubsection{RPC name:~get\_type} {\bf Overview:} -Get the sector\_size field of the given VDI. +Get the type field of the given VDI. \noindent {\bf Signature:} -\begin{verbatim} int get_sector_size (session_id s, VDI ref self)\end{verbatim} +\begin{verbatim} (vdi_type) get_type (session_id s, VDI ref self)\end{verbatim} \noindent{\bf Arguments:} @@ -9836,7 +9836,7 @@ Get the sector\_size field of the given VDI. \noindent {\bf Return Type:} {\tt -int +vdi\_type } @@ -9844,13 +9844,13 @@ value of the field \vspace{0.3cm} \vspace{0.3cm} \vspace{0.3cm} -\subsubsection{RPC name:~get\_type} +\subsubsection{RPC name:~get\_sharable} {\bf Overview:} -Get the type field of the given VDI. +Get the sharable field of the given VDI. \noindent {\bf Signature:} -\begin{verbatim} (vdi_type) get_type (session_id s, VDI ref self)\end{verbatim} +\begin{verbatim} bool get_sharable (session_id s, VDI ref self)\end{verbatim} \noindent{\bf Arguments:} @@ -9868,7 +9868,7 @@ Get the type field of the given VDI. \noindent {\bf Return Type:} {\tt -vdi\_type +bool } @@ -9876,13 +9876,47 @@ value of the field \vspace{0.3cm} \vspace{0.3cm} \vspace{0.3cm} -\subsubsection{RPC name:~get\_sharable} +\subsubsection{RPC name:~set\_sharable} {\bf Overview:} -Get the sharable field of the given VDI. +Set the sharable field of the given VDI. \noindent {\bf Signature:} -\begin{verbatim} bool get_sharable (session_id s, VDI ref self)\end{verbatim} +\begin{verbatim} void set_sharable (session_id s, VDI ref self, bool value)\end{verbatim} + + +\noindent{\bf Arguments:} + + +\vspace{0.3cm} +\begin{tabular}{|c|c|p{7cm}|} + \hline +{\bf type} & {\bf name} & {\bf description} \\ \hline +{\tt VDI ref } & self & reference to the object \\ \hline + +{\tt bool } & value & New value to set \\ \hline + +\end{tabular} + +\vspace{0.3cm} + + \noindent {\bf Return Type:} +{\tt +void +} + + + +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} +\subsubsection{RPC name:~get\_read\_only} + +{\bf Overview:} +Get the read\_only field of the given VDI. + + \noindent {\bf Signature:} +\begin{verbatim} bool get_read_only (session_id s, VDI ref self)\end{verbatim} \noindent{\bf Arguments:} @@ -9908,13 +9942,13 @@ value of the field \vspace{0.3cm} \vspace{0.3cm} \vspace{0.3cm} -\subsubsection{RPC name:~set\_sharable} +\subsubsection{RPC name:~set\_read\_only} {\bf Overview:} -Set the sharable field of the given VDI. +Set the read\_only field of the given VDI. \noindent {\bf Signature:} -\begin{verbatim} void set_sharable (session_id s, VDI ref self, bool value)\end{verbatim} +\begin{verbatim} void set_read_only (session_id s, VDI ref self, bool value)\end{verbatim} \noindent{\bf Arguments:} @@ -9942,13 +9976,13 @@ void \vspace{0.3cm} \vspace{0.3cm} \vspace{0.3cm} -\subsubsection{RPC name:~get\_read\_only} +\subsubsection{RPC name:~get\_other\_config} {\bf Overview:} -Get the read\_only field of the given VDI. +Get the other\_config field of the given VDI. \noindent {\bf Signature:} -\begin{verbatim} bool get_read_only (session_id s, VDI ref self)\end{verbatim} +\begin{verbatim} ((string -> string) Map) get_other_config (session_id s, VDI ref self)\end{verbatim} \noindent{\bf Arguments:} @@ -9966,7 +10000,7 @@ Get the read\_only field of the given VDI. \noindent {\bf Return Type:} {\tt -bool +(string $\rightarrow$ string) Map } @@ -9974,13 +10008,13 @@ value of the field \vspace{0.3cm} \vspace{0.3cm} \vspace{0.3cm} -\subsubsection{RPC name:~set\_read\_only} +\subsubsection{RPC name:~set\_other\_config} {\bf Overview:} -Set the read\_only field of the given VDI. +Set the other\_config field of the given VDI. \noindent {\bf Signature:} -\begin{verbatim} void set_read_only (session_id s, VDI ref self, bool value)\end{verbatim} +\begin{verbatim} void set_other_config (session_id s, VDI ref self, (string -> string) Map value)\end{verbatim} \noindent{\bf Arguments:} @@ -9992,7 +10026,78 @@ Set the read\_only field of the given VDI. {\bf type} & {\bf name} & {\bf description} \\ \hline {\tt VDI ref } & self & reference to the object \\ \hline -{\tt bool } & value & New value to set \\ \hline +{\tt (string $\rightarrow$ string) Map } & value & New value to set \\ \hline + +\end{tabular} + +\vspace{0.3cm} + + \noindent {\bf Return Type:} +{\tt +void +} + + + +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} +\subsubsection{RPC name:~add\_to\_other\_config} + +{\bf Overview:} +Add the given key-value pair to the other\_config field of the given VDI. + + \noindent {\bf Signature:} +\begin{verbatim} void add_to_other_config (session_id s, VDI ref self, string key, string value)\end{verbatim} + + +\noindent{\bf Arguments:} + + +\vspace{0.3cm} +\begin{tabular}{|c|c|p{7cm}|} + \hline +{\bf type} & {\bf name} & {\bf description} \\ \hline +{\tt VDI ref } & self & reference to the object \\ \hline + +{\tt string } & key & Key to add \\ \hline + +{\tt string } & value & Value to add \\ \hline + +\end{tabular} + +\vspace{0.3cm} + + \noindent {\bf Return Type:} +{\tt +void +} + + + +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} +\subsubsection{RPC name:~remove\_from\_other\_config} + +{\bf Overview:} +Remove the given key and its corresponding value from the other\_config +field of the given VDI. If the key is not in that Map, then do nothing. + + \noindent {\bf Signature:} +\begin{verbatim} void remove_from_other_config (session_id s, VDI ref self, string key)\end{verbatim} + + +\noindent{\bf Arguments:} + + +\vspace{0.3cm} +\begin{tabular}{|c|c|p{7cm}|} + \hline +{\bf type} & {\bf name} & {\bf description} \\ \hline +{\tt VDI ref } & self & reference to the object \\ \hline + +{\tt string } & key & Key to remove \\ \hline \end{tabular} diff --git a/tools/libxen/include/xen_vbd.h b/tools/libxen/include/xen_vbd.h index 7b36266a04..14a6685a95 100644 --- a/tools/libxen/include/xen_vbd.h +++ b/tools/libxen/include/xen_vbd.h @@ -72,7 +72,6 @@ typedef struct xen_vbd_record struct xen_vm_record_opt *vm; struct xen_vdi_record_opt *vdi; char *device; - char *image; bool bootable; enum xen_vbd_mode mode; enum xen_vbd_type type; diff --git a/tools/libxen/include/xen_vdi.h b/tools/libxen/include/xen_vdi.h index 26e147250e..9ebb8fd9ee 100644 --- a/tools/libxen/include/xen_vdi.h +++ b/tools/libxen/include/xen_vdi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, XenSource Inc. + * Copyright (c) 2006-2007, XenSource Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,6 +22,7 @@ #include "xen_common.h" #include "xen_crashdump_decl.h" #include "xen_sr_decl.h" +#include "xen_string_string_map.h" #include "xen_vbd_decl.h" #include "xen_vdi_decl.h" #include "xen_vdi_type.h" @@ -73,11 +74,10 @@ typedef struct xen_vdi_record struct xen_crashdump_record_opt_set *crash_dumps; int64_t virtual_size; int64_t physical_utilisation; - int64_t sector_size; - char *location; enum xen_vdi_type type; bool sharable; bool read_only; + xen_string_string_map *other_config; } xen_vdi_record; /** @@ -250,13 +250,6 @@ extern bool xen_vdi_get_physical_utilisation(xen_session *session, int64_t *result, xen_vdi vdi); -/** - * Get the sector_size field of the given VDI. - */ -extern bool -xen_vdi_get_sector_size(xen_session *session, int64_t *result, xen_vdi vdi); - - /** * Get the type field of the given VDI. */ @@ -278,6 +271,13 @@ extern bool xen_vdi_get_read_only(xen_session *session, bool *result, xen_vdi vdi); +/** + * Get the other_config field of the given VDI. + */ +extern bool +xen_vdi_get_other_config(xen_session *session, xen_string_string_map **result, xen_vdi vdi); + + /** * Set the name/label field of the given VDI. */ @@ -313,6 +313,30 @@ extern bool xen_vdi_set_read_only(xen_session *session, xen_vdi vdi, bool read_only); +/** + * Set the other_config field of the given VDI. + */ +extern bool +xen_vdi_set_other_config(xen_session *session, xen_vdi vdi, xen_string_string_map *other_config); + + +/** + * Add the given key-value pair to the other_config field of the given + * VDI. + */ +extern bool +xen_vdi_add_to_other_config(xen_session *session, xen_vdi vdi, char *key, char *value); + + +/** + * Remove the given key and its corresponding value from the + * other_config field of the given VDI. If the key is not in that Map, then + * do nothing. + */ +extern bool +xen_vdi_remove_from_other_config(xen_session *session, xen_vdi vdi, char *key); + + /** * Take an exact copy of the VDI; the snapshot lives in the same * Storage Repository as its parent. diff --git a/tools/libxen/src/xen_vbd.c b/tools/libxen/src/xen_vbd.c index 300f1d857d..893bf70958 100644 --- a/tools/libxen/src/xen_vbd.c +++ b/tools/libxen/src/xen_vbd.c @@ -54,9 +54,6 @@ static const struct_member xen_vbd_record_struct_members[] = { .key = "device", .type = &abstract_type_string, .offset = offsetof(xen_vbd_record, device) }, - { .key = "image", - .type = &abstract_type_string, - .offset = offsetof(xen_vbd_record, image) }, { .key = "bootable", .type = &abstract_type_bool, .offset = offsetof(xen_vbd_record, bootable) }, diff --git a/tools/libxen/src/xen_vdi.c b/tools/libxen/src/xen_vdi.c index 2e50db9e80..10f3fc4066 100644 --- a/tools/libxen/src/xen_vdi.c +++ b/tools/libxen/src/xen_vdi.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, XenSource Inc. + * Copyright (c) 2006-2007, XenSource Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -24,6 +24,7 @@ #include "xen_crashdump.h" #include "xen_internal.h" #include "xen_sr.h" +#include "xen_string_string_map.h" #include "xen_vbd.h" #include "xen_vdi.h" #include "xen_vdi_type_internal.h" @@ -64,12 +65,6 @@ static const struct_member xen_vdi_record_struct_members[] = { .key = "physical_utilisation", .type = &abstract_type_int, .offset = offsetof(xen_vdi_record, physical_utilisation) }, - { .key = "sector_size", - .type = &abstract_type_int, - .offset = offsetof(xen_vdi_record, sector_size) }, - { .key = "location", - .type = &abstract_type_string, - .offset = offsetof(xen_vdi_record, location) }, { .key = "type", .type = &xen_vdi_type_abstract_type_, .offset = offsetof(xen_vdi_record, type) }, @@ -78,7 +73,10 @@ static const struct_member xen_vdi_record_struct_members[] = .offset = offsetof(xen_vdi_record, sharable) }, { .key = "read_only", .type = &abstract_type_bool, - .offset = offsetof(xen_vdi_record, read_only) } + .offset = offsetof(xen_vdi_record, read_only) }, + { .key = "other_config", + .type = &abstract_type_string_string_map, + .offset = offsetof(xen_vdi_record, other_config) } }; const abstract_type xen_vdi_record_abstract_type_ = @@ -105,6 +103,7 @@ xen_vdi_record_free(xen_vdi_record *record) xen_sr_record_opt_free(record->sr); xen_vbd_record_opt_set_free(record->vbds); xen_crashdump_record_opt_set_free(record->crash_dumps); + xen_string_string_map_free(record->other_config); free(record); } @@ -315,7 +314,7 @@ xen_vdi_get_physical_utilisation(xen_session *session, int64_t *result, xen_vdi bool -xen_vdi_get_sector_size(xen_session *session, int64_t *result, xen_vdi vdi) +xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi) { abstract_value param_values[] = { @@ -323,15 +322,14 @@ xen_vdi_get_sector_size(xen_session *session, int64_t *result, xen_vdi vdi) .u.string_val = vdi } }; - abstract_type result_type = abstract_type_int; - - XEN_CALL_("VDI.get_sector_size"); + abstract_type result_type = xen_vdi_type_abstract_type_; + XEN_CALL_("VDI.get_type"); return session->ok; } bool -xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi) +xen_vdi_get_sharable(xen_session *session, bool *result, xen_vdi vdi) { abstract_value param_values[] = { @@ -339,14 +337,15 @@ xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi) .u.string_val = vdi } }; - abstract_type result_type = xen_vdi_type_abstract_type_; - XEN_CALL_("VDI.get_type"); + abstract_type result_type = abstract_type_bool; + + XEN_CALL_("VDI.get_sharable"); return session->ok; } bool -xen_vdi_get_sharable(xen_session *session, bool *result, xen_vdi vdi) +xen_vdi_get_read_only(xen_session *session, bool *result, xen_vdi vdi) { abstract_value param_values[] = { @@ -356,13 +355,13 @@ xen_vdi_get_sharable(xen_session *session, bool *result, xen_vdi vdi) abstract_type result_type = abstract_type_bool; - XEN_CALL_("VDI.get_sharable"); + XEN_CALL_("VDI.get_read_only"); return session->ok; } bool -xen_vdi_get_read_only(xen_session *session, bool *result, xen_vdi vdi) +xen_vdi_get_other_config(xen_session *session, xen_string_string_map **result, xen_vdi vdi) { abstract_value param_values[] = { @@ -370,9 +369,10 @@ xen_vdi_get_read_only(xen_session *session, bool *result, xen_vdi vdi) .u.string_val = vdi } }; - abstract_type result_type = abstract_type_bool; + abstract_type result_type = abstract_type_string_string_map; - XEN_CALL_("VDI.get_read_only"); + *result = NULL; + XEN_CALL_("VDI.get_other_config"); return session->ok; } @@ -457,6 +457,56 @@ xen_vdi_set_read_only(xen_session *session, xen_vdi vdi, bool read_only) } +bool +xen_vdi_set_other_config(xen_session *session, xen_vdi vdi, xen_string_string_map *other_config) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vdi }, + { .type = &abstract_type_string_string_map, + .u.set_val = (arbitrary_set *)other_config } + }; + + xen_call_(session, "VDI.set_other_config", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool +xen_vdi_add_to_other_config(xen_session *session, xen_vdi vdi, char *key, char *value) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vdi }, + { .type = &abstract_type_string, + .u.string_val = key }, + { .type = &abstract_type_string, + .u.string_val = value } + }; + + xen_call_(session, "VDI.add_to_other_config", param_values, 3, NULL, NULL); + return session->ok; +} + + +bool +xen_vdi_remove_from_other_config(xen_session *session, xen_vdi vdi, char *key) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vdi }, + { .type = &abstract_type_string, + .u.string_val = key } + }; + + xen_call_(session, "VDI.remove_from_other_config", param_values, 2, NULL, NULL); + return session->ok; +} + + bool xen_vdi_snapshot(xen_session *session, xen_vdi *result, xen_vdi vdi) { diff --git a/tools/libxen/test/test_bindings.c b/tools/libxen/test/test_bindings.c index f18c5c5ac5..92f2d9b6ca 100644 --- a/tools/libxen/test/test_bindings.c +++ b/tools/libxen/test/test_bindings.c @@ -421,8 +421,7 @@ static xen_vm create_new_vm(xen_session *session, bool hvm) .name_label = "MyRootFS", .name_description = "MyRootFS description", .sr = &sr_record, - .virtual_size = (1 << 21), // 1GiB / 512 bytes/sector - .sector_size = 512, + .virtual_size = (INT64_C(1) << 30), // 1GiB .type = XEN_VDI_TYPE_SYSTEM, .sharable = false, .read_only = false diff --git a/tools/python/scripts/test_hvm_create.py b/tools/python/scripts/test_hvm_create.py index 7cae70539a..35abfe0396 100644 --- a/tools/python/scripts/test_hvm_create.py +++ b/tools/python/scripts/test_hvm_create.py @@ -39,14 +39,13 @@ vm_cfg = { local_vdi_cfg = { 'name_label': 'gentoo.hvm', 'name_description': '', - 'location': 'file:/root/gentoo.amd64.hvm.img', 'virtual_size': 0, - 'sector_size': 0, 'type': 'system', 'parent': '', 'SR_name': 'Local', 'sharable': False, 'read_only': False, + 'other_config': {'location': 'file:/root/gentoo.amd64.hvm.img'}, } local_vbd_cfg = { diff --git a/tools/python/scripts/test_vm_create.py b/tools/python/scripts/test_vm_create.py index e4d8f3023a..6575f153ea 100644 --- a/tools/python/scripts/test_vm_create.py +++ b/tools/python/scripts/test_vm_create.py @@ -39,8 +39,7 @@ vm_cfg = { vdi_cfg = { 'name_label': 'API_VDI', 'name_description': '', - 'virtual_size': 100 * 1024 * 1024, - 'sector_size': 1024, + 'virtual_size': 100 * 1024 * 1024 * 1024, 'type': 'system', 'parent': '', 'SR_name': 'QCoW', @@ -60,14 +59,13 @@ vbd_cfg = { local_vdi_cfg = { 'name_label': 'gentoo.amd64.img', 'name_description': '', - 'location': 'file:/root/gentoo.amd64.img', 'virtual_size': 0, - 'sector_size': 0, 'type': 'system', 'parent': '', 'SR_name': 'Local', 'sharable': False, 'read_only': False, + 'other_config': {'location': 'file:/root/gentoo.amd64.img'}, } local_vbd_cfg = { diff --git a/tools/python/scripts/xapi.py b/tools/python/scripts/xapi.py index 1e49f86d4c..1a07795212 100644 --- a/tools/python/scripts/xapi.py +++ b/tools/python/scripts/xapi.py @@ -40,8 +40,7 @@ VM_LIST_FORMAT = '%(name_label)-18s %(memory_actual)-5s %(VCPUs_number)-5s'\ ' %(power_state)-10s %(uuid)-36s' SR_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(physical_size)-10s' \ '%(type)-10s' -VDI_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(virtual_size)-8s '\ - '%(sector_size)-8s' +VDI_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(virtual_size)-8s' VBD_LIST_FORMAT = '%(device)-6s %(uuid)-36s %(VDI)-8s' TASK_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(status)-8s %(progress)-4s' VIF_LIST_FORMAT = '%(name)-8s %(device)-7s %(uuid)-36s %(MAC)-10s' @@ -96,12 +95,9 @@ OPTIONS = { 'vdi-create': [(('--name-label',), {'help': 'Name for VDI'}), (('--name-description',), {'help': 'Description for VDI'}), - (('--sector-size',), {'type': 'int', - 'help': 'Sector size', - 'default': 0}), (('--virtual-size',), {'type': 'int', 'default': 0, - 'help': 'Size of VDI in sectors'}), + 'help': 'Size of VDI in bytes'}), (('--type',), {'choices': ['system', 'user', 'ephemeral'], 'default': 'system', 'help': 'VDI type'}), @@ -569,8 +565,7 @@ def xapi_vdi_list(args, async = False): if not is_long: print VDI_LIST_FORMAT % {'name_label': 'VDI Label', 'uuid' : 'UUID', - 'virtual_size': 'Bytes', - 'sector_size': 'Sector Size'} + 'virtual_size': 'Bytes'} for vdi in vdis: vdi_struct = execute(server, 'VDI.get_record', (session, vdi)) diff --git a/tools/python/scripts/xapi.vdicfg.py b/tools/python/scripts/xapi.vdicfg.py index 86129bfae9..cb63653550 100644 --- a/tools/python/scripts/xapi.vdicfg.py +++ b/tools/python/scripts/xapi.vdicfg.py @@ -1,7 +1,6 @@ name_label = 'VDI 1' name_description = '' -virtual_size = 10 * 1024 * 1024 -sector_size = 1024 +virtual_size = 10 * 1024 * 1024 * 1024 type = 'system' sharable = False read_only = False diff --git a/tools/python/xen/xend/XendAPI.py b/tools/python/xen/xend/XendAPI.py index ba91b06018..fa790fa75c 100644 --- a/tools/python/xen/xend/XendAPI.py +++ b/tools/python/xen/xend/XendAPI.py @@ -1811,13 +1811,13 @@ class XendAPI(object): VDI_attr_ro = ['SR', 'VBDs', 'physical_utilisation', - 'sector_size', 'type'] VDI_attr_rw = ['name_label', 'name_description', 'virtual_size', 'sharable', - 'read_only'] + 'read_only', + 'other_config'] VDI_attr_inst = VDI_attr_ro + VDI_attr_rw VDI_methods = [('snapshot', 'VDI')] @@ -1832,10 +1832,7 @@ class XendAPI(object): def VDI_get_physical_utilisation(self, session, vdi_ref): return xen_api_success(self._get_VDI(vdi_ref). - get_physical_utilisation()) - - def VDI_get_sector_size(self, session, vdi_ref): - return xen_api_success(self._get_VDI(vdi_ref).sector_size) + get_physical_utilisation()) def VDI_get_type(self, session, vdi_ref): return xen_api_success(self._get_VDI(vdi_ref).type) @@ -1877,6 +1874,14 @@ class XendAPI(object): self._get_VDI(vdi_ref).read_only = bool(value) return xen_api_success_void() + def VDI_get_other_config(self, session, vdi_ref): + return xen_api_success( + self._get_VDI(vdi_ref).other_config) + + def VDI_set_other_config(self, session, vdi_ref, other_config): + self._get_VDI(vdi_ref).other_config = other_config + return xen_api_success_void() + # Object Methods def VDI_snapshot(self, session, vdi_ref): return xen_api_todo() @@ -1896,10 +1901,10 @@ class XendAPI(object): 'VBDs': [], # TODO 'virtual_size': image.virtual_size, 'physical_utilisation': image.physical_utilisation, - 'sector_size': image.sector_size, 'type': image.type, 'sharable': image.sharable, 'read_only': image.read_only, + 'other_config': image.other_config }) # Class Functions diff --git a/tools/python/xen/xend/XendVDI.py b/tools/python/xen/xend/XendVDI.py index f0dda203a8..dd1bc80385 100644 --- a/tools/python/xen/xend/XendVDI.py +++ b/tools/python/xen/xend/XendVDI.py @@ -54,7 +54,6 @@ class XendVDI(AutoSaveObject): SAVED_CFG = ['name_label', 'name_description', - 'sector_size', 'virtual_size', 'physical_utilisation', 'sharable', @@ -67,13 +66,12 @@ class XendVDI(AutoSaveObject): self.sr_uuid = sr_uuid self.name_label = "" self.name_description = "" - self.sector_size = 1024 self.virtual_size = 0 self.physical_utilisation = 0 self.sharable = False self.read_only = False self.type = "system" - self.location = '' + self.other_config = {} def load_config_dict(self, cfg): """Loads configuration into the object from a dict. @@ -144,11 +142,10 @@ class XendVDI(AutoSaveObject): 'name_description': self.name_description, 'virtual_size': self.virtual_size, 'physical_utilisation': self.physical_utilisation, - 'sector_size': self.sector_size, 'sharable': False, 'readonly': False, 'SR': self.sr_uuid, - 'location': self.get_location(), + 'other_config': self.other_config, 'VBDs': []} def get_location(self): @@ -163,12 +160,11 @@ class XendQCoWVDI(XendVDI): self.cfg_path = cfg_path self.physical_utilisation = psize self.virtual_size = vsize - self.sector_size = 512 self.auto_save = True - self.location = 'tap:qcow:%s' % self.qcow_path + self.other_config['location'] = 'tap:qcow:%s' % self.qcow_path def get_location(self): - return self.location + return self.other_config['location'] class XendLocalVDI(XendVDI): def __init__(self, vdi_struct): @@ -182,11 +178,10 @@ class XendLocalVDI(XendVDI): self.name_description = vdi_struct.get('name_description', '') self.physical_utilisation = 0 self.virtual_size = 0 - self.sector_size = 0 self.type = vdi_struct.get('type', '') self.sharable = vdi_struct.get('sharable', False) self.read_only = vdi_struct.get('read_only', False) - self.location = vdi_struct.get('location', 'file:/dev/null') + self.other_config = vdi_struct.get('other_config', {}) def get_location(self): - return self.location + return self.other_config['location'] -- 2.30.2